// context 跨组件传值
 import React from 'react';
// 创建两个组件
const { Provider, Consumer } = React.createContext();

class App extends React.Component{
    render(){
        return(
            <Provider value="Hello World">
                <Child />
            </Provider>
        )
    }
}

const Child = () => {
    return (
        <div> 
            <SubNode />
        </div>
    )
}

const SubNode = () => {
    return (
        <div>
            <Consumer>
                { value => <div>我是孙子节点{value}</div> }
            </Consumer>
        </div>
    )
}

export default App;